﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace findPrime
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("请输入一个正整数");
            int cleannum = 0;
            string num = Console.ReadLine();
            while (!int.TryParse(num, out cleannum))
            {
                Console.WriteLine("请输入一个正整数:");
                num = Console.ReadLine();
            }
            int prime = 2;
            if (cleannum < 2)
            { 
                Console.WriteLine("没有素数因子");
                return;
            }
            Console.WriteLine($"{cleannum}的素数因子有:");
            while(prime <= cleannum)
            {
                if(cleannum % prime == 0)
                {
                    Console.Write(prime+",");
                    while(cleannum%prime == 0)
                    {
                        cleannum = cleannum / prime;
                    }
                }
                prime++;
            }
            return;
        }
    }
}
